
export const storageData = {
	getLoginUser: function() {
		
		// #ifdef H5
		const defaultUser = {"id":7,"idNo":"8001","departmentId":0,"name":"天泽","nickName":null,"mobileNo":null,"userCode":"pfVMqPySxxpTCDJo","pwd":"242d1f9ba9fbda48e877c20dd4de8e9a0074e98add3de4856115ab61863786c5","pwdSalt":"123456","userType":"user","email":null,"avatarUrl":"https://www.hzif.cn/mathematics-attach/share.png/k/kkqaocfnmtsldyzw.jpg","status":"on","remark":null,"roleIds":"","firstLogin":true,"miniType":"math","wechatOpenId":"oUc6b6_NNEP0hJim45s1aWF4KHDo","currentRoleId":-1,"lastLoginTime":null,"parentUserId":-1,"grade":-1,"areaId":-1,"lastUpdateTime":"2024-05-09T13:20:05.000+0000","createTime":"2024-04-22T14:56:03.000+0000","currentRole":null,"roles":null,"accessToken":"NzoxMjM0NTY6QkVFNDg3RkNEQjIzQkY0NTUxQ0RFREY0MzE5MjVDOTE=","statusCn":null,"pwdStrong":null}
		let flag = true
		if(flag){
			return defaultUser
		}
		// #endif 
		
		try {
			const userStr = uni.getStorageSync('loginUser');
			if (userStr) {
				return JSON.parse(userStr)
			}
		} catch (e) {
			console.error('获取登录用户信息异常')
			console.error(e)
		}
		return null
	},
	
	saveLoginUser: function(user) {
		uni.setStorageSync('loginUser' , JSON.stringify(user))
	},
	
	removeLoginUser: function() {
		uni.clearStorage()
	},
	
	saveDataJSON: function(key, val) {
		uni.setStorageSync(key , JSON.stringify(val))
	},
	
	saveData: function(key, val) {
		uni.setStorageSync(key , val)
	},
	
	getDataJSON: function(key) {
		const data = uni.getStorageSync(key)
		console.log('sss: a' + data + 'a')
		if (data && data.length > 0) {
			return JSON.parse(data)
		}
		return data
	},
	getData: function(key) {
		const data = uni.getStorageSync(key)
		return data
	}
}